<?php
namespace Mob \ Controller;

use Think \ Controller;
use Think \ Hook;

class WebApiController extends BaseController {

     private $message;

     public function _initialize() {
    /*

     if(!IS_POST)
     {
     $data['status']=0;
     $data['msg']='request failed!';

     $this->ajaxReturn($data);
      print_r($data);

     }
     */
     }

    public function reportedPosition()
    {
     $latitude = I('latitude');
     $longitude = I('longitude');
     if(empty($latitude)||empty($longitude))
     {
     $data['status']=0;
     $data['msg']='Abnormal location information parameter passing!';

     }else
     {
     $position = D('Position');
     $position->Record();

     }
     $this->ajaxReturn($data);
      print_r($data);


    }

    public function actHallMap()
    {

     $latitude = I('latitude','43.886841','float'); //从请求中取纬度
     $longitude = I('longitude','125.3245','float');  //从请求中经度
     $distance = I('post.distance',20000,'intval');
     $position = array('latitude'=>$latitude,'longitude'=>$longitude);
     $act=D('Activity');
     $count=1;
     $activity = $act->activityMap($position,$data,$distance);
     foreach($activity as &$a)
     {

    $arr =array('serial'=>$count);
    array_unshift($a,$arr);
    $a['user'] = query_user(array('nickname',  'avatar256','usertype'), $a['sponsorUid']);
    $count++;
     }
     $data['status']=1;
     $data['msg']='Successful operation';
     $data['activity']=$activity;
    $this->ajaxReturn($data);


    }




}



